package com.xiaoshuidi.cloud.module.member.enums;

import cn.hutool.core.lang.Assert;
import com.xiaoshuidi.cloud.module.member.enums.topics.TopicsStateEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum ActivitiesStateEnum {
    TO_BE_EFFECTIVE(1,"未生效"), // 待生效
    EFFECTIVE(2,"进行中"), // 生效中
    EXPIRE(3,"已结束"); // 失效


    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        ActivitiesStateEnum activitiesStateEnum = Arrays.stream(ActivitiesStateEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(activitiesStateEnum != null, "ActivitiesStateEnum:{}不存在", code);
        return activitiesStateEnum.getName();
    }
}
